SADD Function ---------------------------------------------------------------------------- Action Returns the address of a specified string variable. Syntax SADD( stringvariable$) Remarks The SADD function returns the address of a string as an offset (near pointer) from the current data segment. The offset is a two-byte integer. SADD is most often used in mixed-language programming to obtain far addresses before passing far strings to procedures written in other languages. The argument stringvariable$ is the string whose offset you want to determine. It can be a simple string variable or a single element of a string array. You cannot use fixed-length string arguments. SADD can be used with both near and far strings. To obtain the segment address of a far string, use the SSEG function. In previous versions of BASIC, SADD was used only for near strings. Note Do not add characters to the beginning or end of a string passed using SADD and LEN. Adding characters can cause BASIC to generate a run-time error. Use this function with caution, because strings can move in the BASIC string space (storage area) at any time. See Also BLOAD; BSAVE; DEF SEG; FRE; PEEK; POKE; SSEG; SSEGADD; VARPTR, VARSEG; VARPTR$ Example The following example illustrates the use of the SADD and SSEG functions. SADD returns the offset address of a variable-length string. SSEG returns the segment of a variable-length string. Typically these functions are used in mixed-language programs or with PEEK, POKE, BLOAD, or BSAVE. In this example, a string is created and then its offset and segment are calculated with SADD and SSEG. The information is then passed to a BASIC SUB procedure that mimics the performance of a non-BASIC print routine. DEFINT A-Z ' Create the string. Text$ = ".... a few well-chosen words" ' Calculate the offset, segment, and length of the string. Offset = SADD(Text$) Segment = SSEG(Text$) Length = LEN(Text$) ' Pass these arguments to the print routine. CALL printit(Segment, Offset, Length) SUB printit (Segment, Offset, Length) CLS ' Set the segment for the PEEK function. DEF SEG = Segment FOR i = 0 TO Length - 1 ' Get each character from memory, convert to ASCII, and display. PRINT CHR$(PEEK(i + Offset)); NEXT i END SUB